package com.sc.nft.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.sc.nft.entity.UserPerformance;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.math.BigDecimal;
import java.util.List;

/**
 * 用户业绩表(sc_user_performance)数据Mapper
 *
 * @author zxy
 * @description 用户市值
 * @since 2023-07-20 17:29:27
 */
@Mapper
public interface UserPerformanceMapper extends BaseMapper<UserPerformance> {

    @Select("select ifnull(sum(term_first_performance+term_second_sales_volume),0) from sc_user_performance where user_id=#{userId} and record_date>= #{start} and is_delete=0")
    BigDecimal getSumTermPerformance(@Param("userId") Long userId, @Param("start") String start );

        @Select("select ifnull(sum(term_first_center_sales_volume+term_center_sales_volume),0) from sc_user_performance where user_id=#{userId} and record_date>= #{start} and is_delete=0")
    BigDecimal getCenterSumTermPerformance(@Param("userId") Long userId, @Param("start") String start );


    Integer getValidUserCount(@Param("userId") Long userId, @Param("downCityId")List<Long> downCityId,@Param("startDate") String startDate);

}
